var express = require('express');
var router = express.Router();
const {exec} = require('child_process');
const {successData} = require("../utils/response");

/* GET home page. */
router.get('/', function (req, res, next) {
  // console.log("=====", process.env.NODE_ENV )
  let devEnv = process.env.NODE_ENV == 'development'
  res.render('index', {
    title: 'Express',
    deployObj: {path: "/deploy.html", title: '项目部署', devEnv: devEnv}
  });
});

router.get("/deployProject", function (req, res) {
  console.log("deployProject===")
  let command = "ls -l"
  // let command = "git clone"
  exec(command, (error, stdout, stderr) => {
    return successData(res, {stdout, error, stderr})
  });
})


module.exports = router;
